package com.bridgeintelligent.tag.webserver.system.service;

import com.bridgeintelligent.tag.user.mgmt.pojo.User;
import com.bridgeintelligent.tag.utils.SecurityHelper;
import com.bridgeintelligent.tag.webserver.system.entity.DimUseRecord;
import com.bridgeintelligent.tag.webserver.system.mapper.DimUseRecordMapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Slf4j
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class)
public class DimUseRecordServiceImpl implements DimUseRecordService{

    private DimUseRecordMapper mapper;

    @Override
    public void addRecord(DimUseRecord record) {
        User user = SecurityHelper.currentUser();
        record.setUserId(user.getUserId());
        //先根据ID删除，主要是宏观画像，或者looklike有新增有修改
        mapper.delByIdId(record.getId());
        mapper.addRecord(record);
    }
}
